<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" title="预警信息详情">
		</u-navbar>
		<uc-content :loading="loading">
			<view class="list-item">
				<view class="list-bottom">
					<view>火情预警名称:</view>
					<view>{{fireAlarmInfo.name}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>企业:</view>
					<view>{{fireAlarmInfo.enterpriseName}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>设备:</view>
					<view>{{fireAlarmInfo.equipmentName}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>预警时间:</view>
					<view>{{fireAlarmInfo.alarmTime |dateFormat}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>预警信息:</view>
					<view>{{fireAlarmInfo.alarmInfo}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>巡检人员确认时间:</view>
					<view>{{fireAlarmInfo.userConfirmTime | dateFormat}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>反馈内容:</view>
					<view>{{fireAlarmInfo.feedback}}</view>
				</view>
			</view>
			<view class="list-item">
				<view class="list-bottom">
					<view>详细地址:</view>
					<view>{{fireAlarmInfo.location}}</view>
				</view>
			</view>
			<view class="list-item" v-if="fireAlarmInfo.fileUrl">
				<view class="list-img">
					<view class="text">确认误报图片:</view>
					<view class="img" >
						<u-image height="450rpx" :src="fireAlarmInfo.fileUrl+'?x-oss-process=style/zip_app'" mode="aspectFit">
							<u-loading slot="loading"></u-loading>
						</u-image>
					</view>
				</view>
			</view>
			<u-button v-if="fireAlarmInfo.feedtype==-1" @click="showToast" type="primary"
				shape="square">处置</u-button>
		</uc-content>
		<u-toast ref="uToast">
			<view>
				已确认处置
			</view>
		</u-toast>
		<u-popup v-model="shows" mode="center">
			<view style="padding: 25px; text-align: center;">
				<u-form ref="MaintenanceinfoForm">
					<span>请选择处置方法</span>
					<view>
						<u-button @click="Misinformation" type="primary" shape="square" size="mini"
							style="margin-top: 15px; margin-left: 5px;">设备误报</u-button>
						<u-button @click="TureFire" type="primary" shape="square" size="mini"
							style="margin-left: 15px;">实际火情</u-button>
					</view>
				</u-form>
			</view>
		</u-popup>

		<!-- 点击实际火情弹出框 -->
		<u-popup v-model="TFire" mode="center">
			<view style="padding: 25px;">
				<u-form :model="fireAlarmData" ref="fireAlarmInfoForm" :rules="fireAlarmRules" label-width="100px">
					<u-form-item label="详细地址">
						<u-input v-model="fireAlarmData.loaction" />
					</u-form-item>
					<u-form-item label="起火描述">
						<u-input v-model="fireAlarmData.fireDescription" />
					</u-form-item>
					<u-form-item label="起火原因">
						<u-input v-model="fireAlarmData.fireCause" />
					</u-form-item>
					<!-- <u-form-item label="实时视频"><u-input v-model="fireAlarmData.realTimeVideo" /></u-form-item> -->
					<!-- <u-form-item label="建筑类型">
							<u-input type="text" style="display:none" v-model="Maintenan ceData.maintenanceUser" />
							<u-input v-model="maintenanceUserValue" :type="type" :border="border" placeholder="选择企业" @click="maintenanceUserShow = true" />
							<u-action-sheet :list="maintenanceUserList" v-model="maintenanceUserShow" @click="maintenanceUserCallback"></u-action-sheet>
						</u-form-item> -->
					<u-button @click="cancel" type="primary" shape="square" size="medium"
						style="margin-top: 15px; margin-left: 5px;">取消</u-button>
					<u-button @click="submit" type="primary" shape="square" size="medium" style="margin-left: 15px;">提交
					</u-button>
				</u-form>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import utils from "../../../utils/utils.js"
	export default {
		data() {
			return {
				loading: false,
				alarmInfoId: "",
				fireAlarmInfo: [],
				ucId: "",
				fireAlarmData: {},
				shows: false,
				feedtypes: 'aa',
				TofireAlarm: false,
				TFire: false,
				fireAlarmRules: {}
			}
		},
		onLoad(e) {
			this.getInFireAlarmInfo(e.ucId)
		},
		onShow() {
			this.initView(this.ucId)
		},
		methods: {
			initView(val) {
				this.loading = true
				this.fireAlarmInfo = {}
				this.pageNum = 0
				// this.getNoticeInfo(val)
			},
			showToast() {
				window.native.equRounds({
					title: this.fireAlarmInfo.equipmentId,
					drill: this.fireAlarmInfo.fireDrill,
					ucId: this.fireAlarmInfo.ucId,
					taskId: this.fireAlarmInfo.taskId,
					token: utils.getStorageSync("authorization")
				})
			},
			// 误报事件
			Misinformation() {
				this.utils.request("/api/app/fireAlarmInfo/updateInFireAlarmInfo", {
					ucId: this.fireAlarmInfo.ucId,
					feedtype: 0,
					feedback: "设备误报"
				}, "post", "app", true).then(res => {
					console.log(res)
					this.shows = false;
					uni.navigateBack({
						delta: 1
					})
				}).catch(error => {
					console.log(error)
				})
			},

			//实际火情点击事件 
			TureFire() {
				// this.TFire = true;
				// this.fireAlarmData.ucId = this.fireAlarmInfo.ucId;
				// this.fireAlarmData.name = this.fireAlarmInfo.name;
				// this.fireAlarmData.enterpriseId = this.fireAlarmInfo.enterpriseId;
				// this.fireAlarmData.alarmInfoId = this.alarmInfoId;
				// this.fireAlarmData.location = this.fireAlarmInfo.location;
				// this.fireAlarmData.equipmentId = this.fireAlarmInfo.equipmentId;
				
				window.native.equRounds({
					title: this.fireAlarmInfo.equipmentId,
					drill: this.fireAlarmInfo.fireDrill,
					ucId: this.fireAlarmInfo.ucId,
					taskId: this.fireAlarmInfo.taskId,
					token: utils.getStorageSync("authorization")
				})
			},
			getInFireAlarmInfo(val) {
				this.utils.request("/api/app/fireAlarmInfo/getInFireAlarmInfoVo", {
					ucId: val
				}, "post", "app", true).then(res => {
					console.log(res.data)
					this.loading = false
					this.fireAlarmInfo = res.data
					// this.getInFireAlarmInfo(val)
				}).catch(error => {
					this.loading = false
					console.log(error)
				})
			},
			updateInFireAlarmInfo() {
				this.utils.request("/api/app/fireAlarmInfo/updateInFireAlarmInfo", {
					ucId: this.fireAlarmInfo.ucId,
					feedtype: 2,
					feedback: "火情"
				}, "post", "app", true).then(res => {
					console.log(res)

				}).catch(error => {
					console.log(error)
				})
			},
			// 点击提交
			submit() {
				console.log(this.fireAlarmData)
				this.utils.request("/api/app/fireInfo/addInFireInfo", this.fireAlarmData, "post", "app", true).then(
					res => {
						console.log(`返回结果：`, res)
						this.shows = false
						this.TFire = false
						this.fireAlarmData = {}
						this.updateInFireAlarmInfo()
						this.getInFireAlarmInfo(this.alarmInfoId)
						uni.navigateBack({
							delta: 1
						})
					}).catch(error => {
					console.log(error)
				})
			},
			// 取消按钮
			cancel() {
				this.shows = false
				this.TFire = false
				this.fireAlarmData = {}
			},
		}
	}
</script>